package com.guazai.project.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.guazai.common.pojo.User;
import com.guazai.project.common.DeleteRequest;
import com.guazai.project.model.dto.user.*;
import com.guazai.project.model.vo.LoginUserVO;
import com.guazai.project.model.vo.UserVO;
import com.guazai.project.model.vo.UserVoucherVO;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户服务
 *
 * @author guazai
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     *
     * @param userAccount   用户账户
     * @param userPassword  用户密码
     * @param checkPassword 校验密码
     * @return 新用户 id
     */
    long userRegister(String userAccount, String userPassword, String checkPassword);

    /**
     * 添加一个用户
     *
     * @param user
     * @return
     */
    long addUser(User user);

    /**
     * 用户登录
     *
     * @param userAccount  用户账户
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    User userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 分页查询
     * @param userQueryRequest
     * @return
     */
    Page<UserVO> listUserVOByPage(UserQueryRequest userQueryRequest);

    /**
     * 将User转化成UserVO
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    /**
     * 获取凭证
     * @param request
     * @return
     */
    User getVoucher(HttpServletRequest request);

    /**
     * 修改用户并删除头像
     *
     * @param userUpdateRequest
     * @return
     */
    boolean updateUser(UserUpdateRequest userUpdateRequest);

    /**
     * 删除用户
     * @param deleteRequest
     * @return
     */
    boolean removeUser(DeleteRequest deleteRequest);

    /**
     * 删除用户（多个id）
     *
     * @param deleteListRequest
     * @param request
     * @return
     */
    boolean deleteUserByIds(DeleteListRequest deleteListRequest, HttpServletRequest request);

    /**
     * 修改用户密码
     *
     * @param userUpdatePasswordRequest
     * @param id
     * @return
     */
    boolean updatePassword(UserUpdatePasswordRequest userUpdatePasswordRequest, Long id);

    /**
     * 修改用户名
     * @param user
     * @return
     */
    boolean updateUserName(User user);

    /**
     * 发送验证码邮件
     *
     * @param to
     * @param request
     * @return
     */
    Boolean sendCodeEmail(String to, HttpServletRequest request);

    LoginUserVO userLoginByEmail(UserLoginByEmailRequest userLoginByEmailRequest, HttpServletRequest request);

    /**
     * 绑定邮箱
     * @param userBindEmailRequest
     * @param request
     * @return
     */
    Boolean bindEmail(UserBindEmailRequest userBindEmailRequest, HttpServletRequest request);

    /**
     * 解绑邮箱
     * @param request
     * @return
     */
    Boolean unBindEmail(HttpServletRequest request);

    /**
     * 更新秘钥
     * @param request
     * @return
     */
    UserVoucherVO updateVoucher(HttpServletRequest request);
}
